import Vue from 'vue'
// 引入le路由
import Router from 'vue-router'

// 引入组件
import login from '../components/login/login.vue'
import register from '../components/register/register.vue'
import persion from '../components/persion/persion.vue'
import product from '../components/product/product.vue'
import service from '../components/service/service.vue'
import hello from '../components/hello/hello.vue'
import article from '../components/article/article.vue'
import hexiao from '../components/hexiao/hexiao.vue'
// use安装一下
Vue.use(Router)
// 实例化路由
const router = new Router({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: login },
    { path: '/register', component: register },
    { path: '/persion', component: persion },
    { path: '/product', component: product },
    { path: '/service', component: service },
    { path: '/hello', component: hello },
    { path: '/article', component: article },
    { path: '/hexiao', component: hexiao }
  ]
})
// 导航守卫
// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') {
//     next()
//   } else {
//     const token = localStorage.getItem('token')
//     token ? next() : next('/login')
//   }
// })
// 导出路由
export default router
